package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @ApiOperation("分类分页查询")
    Page<Category> page(CategoryPageQueryDTO categoryPageQueryDTO);

    @ApiOperation("修改分类")
    @Update("update category set type = #{type},name = #{name} where id = #{id}")
    void update(CategoryDTO categoryDTO);

    @ApiOperation("启用禁用分类")
    @Update("update category set status = #{status} where id = #{id}")
    void startOrStop(Integer status, Long id);

    @ApiOperation("新增分类")
    @Insert("insert into category (type,name,status,create_time,update_time,create_user,update_user) values (#{type},#{name},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    @ApiOperation("删除分类")
    @Delete("delete from category where id = #{id}")
    void delete(Long id);

    @ApiOperation("根据类型查询分类")
    @Select("select * from category where type = #{type}")
    List<Category> list(Integer type);
}
